package com.soin.smc.models.service.impl;

import com.soin.smc.common.utils.DateUtils;
import com.soin.smc.models.domain.District;
import com.soin.smc.models.mapper.DistrictMapper;
import com.soin.smc.models.service.DistrictService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 区划信息Service业务层处理
 *
 * @author adinlead
 * @date 2023-03-02
 */
@Service
public class DistrictServiceImpl implements DistrictService {
    @Resource
    private DistrictMapper districtMapper;

    /**
     * 查询区划信息
     *
     * @param id 区划信息主键
     * @return 区划信息
     */
    @Override
    public District selectDistrictById(Long id) {
        return districtMapper.selectDistrictById(id);
    }

    /**
     * 查询区划信息列表
     *
     * @param district 区划信息
     * @return 区划信息
     */
    @Override
    public List<District> selectDistrictList(District district) {
        return districtMapper.selectDistrictList(district);
    }

    /**
     * 新增区划信息
     *
     * @param district 区划信息
     * @return 结果
     */
    @Override
    public int insertDistrict(District district) {
        district.setCreateTime(DateUtils.getNowDate());
        return districtMapper.insertDistrict(district);
    }

    /**
     * 修改区划信息
     *
     * @param district 区划信息
     * @return 结果
     */
    @Override
    public int updateDistrict(District district) {
        district.setUpdateTime(DateUtils.getNowDate());
        return districtMapper.updateDistrict(district);
    }

    /**
     * 批量删除区划信息
     *
     * @param ids 需要删除的区划信息主键
     * @return 结果
     */
    @Override
    public int deleteDistrictByIds(Long[] ids) {
        return districtMapper.deleteDistrictByIds(ids);
    }

    /**
     * 删除区划信息信息
     *
     * @param id 区划信息主键
     * @return 结果
     */
    @Override
    public int deleteDistrictById(Long id) {
        return districtMapper.deleteDistrictById(id);
    }
}
